/*   1:    */ package tt.dz.web.controller.manager;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import java.util.ArrayList;
/*   5:    */ import java.util.HashMap;
/*   6:    */ import java.util.Iterator;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.annotation.Resource;
/*  10:    */ import javax.servlet.http.HttpServletRequest;
/*  11:    */ import javax.servlet.http.HttpServletResponse;
/*  12:    */ import org.apache.commons.collections.CollectionUtils;
/*  13:    */ import org.springframework.stereotype.Controller;
/*  14:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  15:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  16:    */ import tt.dz.biz.service.channel.PayChannelService;
/*  17:    */ import tt.dz.common.LogUtil;
/*  18:    */ import tt.dz.vo.PayChannelVO;
/*  19:    */ import tt.dz.vo.ResponseModle;
/*  20:    */ import tt.dz.web.controller.BaseController;
/*  21:    */ 
/*  22:    */ @Controller
/*  23:    */ public class PayChannelController
/*  24:    */   extends BaseController
/*  25:    */ {
/*  26:    */   @Resource(name="payChannelService")
/*  27:    */   private PayChannelService payChannelService;
/*  28:    */   
/*  29:    */   @RequestMapping(value={"/listAllPayChannel"}, produces={"application/json;charset=UTF-8"})
/*  30:    */   @ResponseBody
/*  31:    */   public String listAllPayChannel()
/*  32:    */   {
/*  33: 38 */     ResponseModle responseModle = null;
/*  34:    */     try
/*  35:    */     {
/*  36: 40 */       List<PayChannelVO> payChannelList = this.payChannelService.listAllPayChannel();
/*  37: 41 */       responseModle = new ResponseModle("success", payChannelList);
/*  38:    */     }
/*  39:    */     catch (Exception e)
/*  40:    */     {
/*  41: 43 */       LogUtil.error("查询支付渠道异常", e);
/*  42: 44 */       responseModle = new ResponseModle("error", new ArrayList());
/*  43:    */     }
/*  44: 46 */     return JSON.toJSONString(responseModle);
/*  45:    */   }
/*  46:    */   
/*  47:    */   @RequestMapping(value={"/mapAllPayChannel"}, produces={"application/json;charset=UTF-8"})
/*  48:    */   @ResponseBody
/*  49:    */   public String mapAllPayChannel()
/*  50:    */   {
/*  51: 56 */     ResponseModle responseModle = null;
/*  52:    */     try
/*  53:    */     {
/*  54: 58 */       List<PayChannelVO> payChannelList = this.payChannelService.listAllPayChannel();
/*  55: 59 */       Iterator<PayChannelVO> iterator = payChannelList.iterator();
/*  56: 60 */       PayChannelVO payChannelVO = null;
/*  57: 61 */       Map<String, Object> resultMap = new HashMap();
/*  58: 62 */       while (iterator.hasNext())
/*  59:    */       {
/*  60: 63 */         payChannelVO = (PayChannelVO)iterator.next();
/*  61: 64 */         resultMap.put(payChannelVO.getChannelCode(), payChannelVO);
/*  62:    */       }
/*  63: 66 */       responseModle = new ResponseModle("success", resultMap);
/*  64:    */     }
/*  65:    */     catch (Exception e)
/*  66:    */     {
/*  67: 68 */       LogUtil.error("查询支付渠道异常", e);
/*  68: 69 */       responseModle = new ResponseModle("error", new ArrayList());
/*  69:    */     }
/*  70: 71 */     return JSON.toJSONString(responseModle);
/*  71:    */   }
/*  72:    */   
/*  73:    */   @RequestMapping(value={"/modifyPayChannel"}, produces={"application/json;charset=UTF-8"})
/*  74:    */   @ResponseBody
/*  75:    */   public String modifyPayChannel(HttpServletRequest request, HttpServletResponse response)
/*  76:    */   {
/*  77: 83 */     boolean excuteFlag = false;
/*  78:    */     try
/*  79:    */     {
/*  80: 85 */       String modifyType = request.getParameter("modifyType");
/*  81: 86 */       PayChannelVO payChannelVO = (PayChannelVO)JSON.parseObject(request.getParameter("payChannelVO"), PayChannelVO.class);
/*  82:    */       List<PayChannelVO> tmpList;
/*  83: 87 */       if ("insert".equals(modifyType))
/*  84:    */       {
/*  85: 88 */         PayChannelVO rsByCode = this.payChannelService.queryChannelByCode(payChannelVO.getChannelCode());
/*  86: 89 */         if (null != rsByCode) {
/*  87: 90 */           return JSON.toJSONString(assemblyResponseData(false, "存在相同的渠道编码，请输入新的渠道编码。"));
/*  88:    */         }
/*  89: 92 */         tmpList = this.payChannelService.queryChannelListByName(payChannelVO.getChannelName());
/*  90: 93 */         if (CollectionUtils.isNotEmpty(tmpList)) {
/*  91: 94 */           return JSON.toJSONString(assemblyResponseData(false, "存在相同名称的渠道信息，请输入新的渠道名称。"));
/*  92:    */         }
/*  93: 96 */         excuteFlag = this.payChannelService.insertPayChannel(payChannelVO);
/*  94:    */       }
/*  95: 97 */       else if ("update".equals(modifyType))
/*  96:    */       {
/*  97: 98 */          tmpList = this.payChannelService.queryChannelListByName(payChannelVO.getChannelName());
/*  98: 99 */         if (CollectionUtils.isNotEmpty(tmpList)) {
/*  99:100 */           for (PayChannelVO tmpvo : tmpList) {
/* 100:101 */             if (!tmpvo.getChannelCode().equals(payChannelVO.getChannelCode())) {
/* 101:102 */               return JSON.toJSONString(assemblyResponseData(false, "存在相同名称的渠道信息，请输入新的渠道名称。"));
/* 102:    */             }
/* 103:    */           }
/* 104:    */         }
/* 105:106 */         excuteFlag = this.payChannelService.updatePayChannel(payChannelVO);
/* 106:    */       }
/* 107:    */     }
/* 108:    */     catch (Exception e)
/* 109:    */     {
/* 110:109 */       LogUtil.error("更改支付渠道异常", e);
/* 111:    */     }
/* 112:111 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/* 113:    */   }
/* 114:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.manager.PayChannelController
 * JD-Core Version:    0.7.0.1
 */